#include "fig_app.h"
#include "build.h"
#include "fig_vars.h"

#include "util/log.h"				// log

#ifdef _PLATFORM_WIN32
int WINAPI WinMain ( HINSTANCE hInst, HINSTANCE hPrevInst, char * cmdParam, int cmdShow )
#else

int main(int argc,char *argv[])
#endif
{
	const std::string Name = std::string(BUILD_NAME) + " : " + BUILD_ID + "               (Built on " + __DATE__ + " )";
    
	
	 //non-iPhone5
	 float	Width = 640; float   Height =  960;
    
	// iPad
	//float	Width = 768;
	//float   Height =  1024;

	//iPhone5
	// float	Width = 640;
	// float   Height =  1136;

	 // android 
	// float	Width = 480;
	// float   Height =  800;

	// iPhone 5s
	//float	Width = 640.0f; float   Height =  1136.0f;// Width *= (1024.0f/Height); Height *= (1024.0f/Height);

	// iPhone 6
	//float	Width = 750.0f; float   Height =  1334.0f; //Width *= (1024.0f/Height); 
	//Height *= (1024.0f/Height);

	

#ifdef _PLATFORM_ANDROID
	// Width = 0;		// 0 means max resolution of device
	 //Height =  0;	// 0 means max resolution of device
#endif

    
#ifdef _PLATFORM_WIN32
	GENWin32Handler*	pHandler = new GENWin32Handler(hInst);
#else
    
	GENWin32Handler*	pHandler = new GENWin32Handler();
#endif
	
	
	if (!pHandler->InitWindow(Name, Name, 0, 0, (int)Width,(int)Height))
	{
		return -1;
	}
 
	std::string Path	= pHandler->GetSaveFolder();
	std::string Log		= Path + "ac.log";
	std::string Config	= Path + "ac.lua";
    
	g_pApp = new FIGApp (pHandler, Config, Log);
	g_pApp->Init();
    
	// set the real size we got according to hardware
    GraphicsUtil::SetWindowSize( GetGraphics()->GetScreenWidth() , GetGraphics()->GetScreenHeight());

	//Fighter::Instance().SetScale(0.6f);   
	while (g_pApp->Tick())
	{
	};
    
	_LOG(MSG_INIT, "About to quit normally");
	FIGVars::Instance()->Save();
	g_pApp->Shutdown();
	UTIL_SAFE_DELETE(g_pApp);
	return 1;
}
